﻿using UnityEditor;
using UnityEngine;

namespace HKTools
{
    /// <summary>
    /// 摄像机多目标切换管理工具，AreaTargetItem 控制脚本
    /// </summary>
    public class HK_AreaTarget : HK_BaseTarget
    {
        public Vector3 TargetPos
        {
            get { return transform.position + transform.forward * distance; }
        }

        public Vector3 TargetDir
        {
            get { return transform.position - TargetPos; }
        }

        [Header("默认距离（Green）：")]
        public float distance = 2;

        [Header("Area宽度：")]
        public float areaWidth = 20;

        [Header("Area长度：")]
        public float areaLength = 10;

        public override void Awake()
        {
            base.Awake();
            TargetKind = HK_TargetKind.AreaTarget;
        }

        void OnDrawGizmosSelected()
        {
            var radius = 1;

            Gizmos.color = Color.green;
            Gizmos.DrawRay(transform.position, transform.forward * distance);
            Gizmos.DrawSphere(transform.position + transform.forward * distance, radius);

            Gizmos.DrawWireCube(transform.position + transform.forward * distance, new Vector3(areaWidth, 2, areaLength));
        }
    }
}